/**
    老年人 组件
**/
(function (vc) {

    vc.extends({
        data: {
            viewGovOldPersonInfo: {
                govPersonsAnswers: [],
                oldId: '',
                caId: '',
                govCommunityId: '',
                personName: '',
                personTel: '',
                personAge: '',
                contactPerson: '',
                contactTel: '',
                servPerson: '',
                servTel: '',
                ramark: '',

            }
        },
        _initMethod: function () {
            let _oldId = vc.getParam("oldId");
            //根据请求参数查询 查询 业主信息
            vc.component._listGovOldPersons(_oldId);
            $that._listGovPersonsAnswer(_oldId);
        },
        _initEvent: function () {
            vc.on('viewGovOldPersonInfo', 'chooseGovOldPerson', function (_app) {
                vc.copyObject(_app, vc.component.viewGovOldPersonInfo);
            });

            vc.on('viewGovOldPersonInfo', 'onIndex', function (_index) {
                vc.component.viewGovOldPersonInfo.index = _index;
            });

        },
        methods: {

            _openSelectGovOldPersonInfoModel() {
                vc.emit('chooseGovOldPerson', 'openChooseGovOldPersonModel', {});
            },
            _openAddGovOldPersonInfoModel() {
                vc.emit('addGovOldPerson', 'openAddGovOldPersonModal', {});
            },
            _toViewAnswerTitle: function (_govPersonsAnswer) {
                vc.jumpToPage('/admin.html#/pages/gov/reportInfoAnswerValueManage?personId=' + _govPersonsAnswer.personId + '&healthId=' + _govPersonsAnswer.healthId);
            },
            _listGovPersonsAnswer: function (_oldId) {
                var param = {
                    params: {
                        personId: _oldId,
                        caId: vc.getCurrentCommunity().caId,
                        page: 1,
                        row: 10
                    }
                };

                //发送get请求
                vc.http.apiGet('/govHealthAnswer/queryGovHealthAnswer',
                    param,
                    function (json, res) {
                        vc.component.viewGovOldPersonInfo.govPersonsAnswers = [];
                        var _govOldPersonManageInfo = JSON.parse(json);
                        vc.component.viewGovOldPersonInfo.total = _govOldPersonManageInfo.total;
                        vc.component.viewGovOldPersonInfo.records = _govOldPersonManageInfo.records;
                        vc.component.viewGovOldPersonInfo.govPersonsAnswers = _govOldPersonManageInfo.data;
                        vc.emit('pagination', 'init', {
                            total: vc.component.viewGovOldPersonInfo.records,
                            currentPage: param.params.page
                        });
                    }, function (errInfo, error) {
                        console.log('请求失败处理');
                    }
                );
            },
            _listGovOldPersons: function (_oldId) {
                var param = {
                    params: {
                        govPersonId: _oldId,
                        caId: vc.getCurrentCommunity().caId,
                        page: 1,
                        row: 10
                    }
                };

                //发送get请求
                vc.http.apiGet('/govOldPerson/queryGovOldPerson',
                    param,
                    function (json, res) {
                        var _govOldPersonManageInfo = JSON.parse(json);
                        vc.component.viewGovOldPersonInfo = _govOldPersonManageInfo.data[0];

                    }, function (errInfo, error) {
                        console.log('请求失败处理');
                    }
                );
            },
            _goBack: function () {
                vc.goBack();
            }

        }
    });

})(window.vc);
